<%--
  Created by IntelliJ IDEA.
  User: 91228
  Date: 2022/8/3
  Time: 15:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<html>
<head>
    <title>Title</title>
    <style>
        #dv{
            width:700px;
            margin:10px auto;
        }
        td{
            padding:1px
        }
        th{
            background-color:rgb(181,171,171);
        }
        tr:nth-child(odd){
            background-color:rgb(226,234,209);
        }
        tr:nth-child(even){
            background-color:rgb(235,237,230);
        }
        .flooter{
            float: right;
            padding-right: 150px;
        }
    </style>
</head>
<body>
<div id="dv">
    <div>
        <form action="${pageContext.request.contextPath }/book/bookList.do" method="post">
            图书分类：
            <select name="categoryId">
                <option value="0">全部</option>
                <c:forEach items="${list}" var="list">
                    <option value="${list.id}">${list.name}</option>
                </c:forEach>
            </select>
            <input type="hidden" name="pageIndex" value="1"/>
            <input type="submit" value="查询"/>
            <input type="button" value="新增电子图书" onclick="location.href='${pageContext.request.contextPath}/book/bookadd'"/>
        </form>
    </div>
    <h1>电子图书列表</h1>
    <table border="1" id="tab">
    <tr>
        <th>图书编号</th>
        <th>图书名称</th>
        <th>图书摘要</th>
        <th>上传人</th>
        <th>上传时间</th>
        <th>操作</th>
    </tr>
<c:forEach items="${entryList}" var="entryList">
    <tr>
        <td>${entryList.id}</td>
        <td>${entryList.title}</td>
        <td>${entryList.summary}</td>
        <td>${entryList.uploaduser}</td>
        <td><fmt:formatDate value="${entryList.createdate}" pattern="yyyy-MM-dd"/></td>
        <td>
            <a href="${pageContext.request.contextPath}/book/modify/${entryList.id}">修改</a>

            <a href="javascript:void(0)" onclick="del(${entryList.id})">删除</a>
        </td>
    </tr>
</c:forEach>
    <tr>
        <td colspan="6" align="center"></td>
    </tr>
    </table>
    <p class="flooter">

        <a href="${pageContext.request.contextPath }/book/bookList.do?pageIndex=1">首页</a>
        <c:if test="${pageIndex>1}">
            <a href="${pageContext.request.contextPath }/book/bookList.do?pageIndex=${pageIndex-1}">上一页</a>
        </c:if>
        <c:if test="${pageIndex<pages}">
            <a href="${pageContext.request.contextPath }/book/bookList.do?pageIndex=${pageIndex+1}">下一页</a>
        </c:if>
        <a href="${pageContext.request.contextPath }/book/bookList.do?pageIndex=${pages}">末页</a>
        第${pageIndex }页/共${pages }页(${count}条记录)
    </p>
</div>
<script type="text/javascript">
    function del(id){
        var tag=confirm("确定要删除吗?");
        if(tag){
            location.href="${pageContext.request.contextPath}/book/bookdel?id="+id;
        }
    }
</script>
</body>
</html>
